<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
    String importMsg = "";
    if (request.getSession().getAttribute("msg") != null) {
        importMsg = request.getSession().getAttribute("msg").toString();
    }
    request.getSession().setAttribute("msg", "");
%>
<head lang="en">
    <meta charset="UTF-8">
    <%@include file="style.jsp" %>
    <%@include file="script.jsp" %>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/orderlang/distributor/css/product_import.css"/>
    <title>我的订货郎</title>
</head>
<body>
<div id="container_1" style="height:100%">
    <div style="position: relative">
        <%@include file="header.jsp" %>
    </div>
    <div id="content" class="clearfix">
        <%@include file="left_menu.jsp" %>
         <!--内容部分-->
        <div class="right-content" style="margin:75px 50px 0 213px;">
            <p class="brand">
                <a>商品</a>><a href="${pageContext.request.contextPath}/product/findProductList">商品查询</a>><a class="now">商品导入</a>
            </p>
            <div class="content">
                <div class="step active1 clearfix">
                    <div class="step1 fl">
                        <div class="first fl">
                            <span>1</span>
                            下载商品导入模板
                        </div>
                        <p class="fl"></p>
                    </div>
                    <div class="step2 fl">
                        <div class="second fl">
                            <span>2</span>
                            上传商品资料
                        </div>
                        <p class="fl"></p>
                    </div>
                    <div class="step3 fl">
                        <div class="third fl">
                            <span>3</span>
                            导入完成
                        </div>
                        <p class="fl"></p>
                    </div>
                </div>
                <div class="content-block">
                    <p class="download">
                        <a href="${pageContext.request.contextPath}/exceltemplet/test.xlsx">下载模板</a>
                    </p>
                    <form id="file-form" action="${pageContext.request.contextPath}/upload/importProduct" method="post" enctype="multipart/form-data">
                        <input id="file-upload" type="file" name="filename" accept="xlsx,xls" onchange="importProduct()" style="display: none"/>
                        <p class="file-upload" onclick="$('#file-upload').click();">
                            <span>导入文件</span>
                            <s></s>
                        </p>
                        <font id="importMsg" color="red"><%=importMsg%></font>
                    </form>
                    <h5>模板表格使用说明：</h5>
                    <h5>批量导入商品是只通过excel模板，批量添加多个商品；</h5>
                    <h5>请按照数据模板的格式准备导入数据，模板中的表头名称不可更改，表头行不能删除；</h5>
                    <h5>1.文件后缀名必须为：xls 或xlsx （即Excel格式），文件大小不得大于2M。</h5>
                    <h5>2.商品编码允许为空，为空则系统为其生成编码。</h5>
                    <h5>3.商品名称不允许为空，一旦为空，则本行数据不允许导入。</h5>
                    <h5>4.商品导入不支持重复导入。对“商品编码”相同的商品，将不会被导入。</h5>
                    <h5>5.多规格名称和值必需先在系统中设置好，未找到的规格值数据行将不允许导入</h5>
                </div>
            </div>
        </div>
        <script src="${pageContext.request.contextPath}/static/orderlang/distributor/js/customer_import.js"></script>
        <!--内容部分结束-->
    </div>
</div>
<script type="text/javascript">
	function importProduct(){
		var file = $("#file-upload").val();
		var fileName = getFileName(file);
		function getFileName(o){
		    var pos=o.lastIndexOf("\\");
		    return o.substring(pos+1);  
		}
		if(fileName.indexOf("xls")!=-1||fileName.indexOf("xlsx")!=-1){
			$("#file-form").submit();
		} else {
			alertBox(0,"必须上传xls或xlsx格式的文件!");
		}
	}
    $(document).ready(function() {
        var msg = "";
        if ($("#importMsg").text() != null) {
            msg = $("#importMsg").text();
        }
        if (msg != "") {
            alertBox(0,msg);
        }
    });
</script>
</body>
</html>